/**
 * Description: 目的是为了对照AnnoymousInner，也就是不通过匿名内部类，而是通过正常的继承抽象类来实现一样的结果
 * Class Name:AnnoymousInner_Contrast
 * Date:2022/2/11 14:19
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第6章_面向对象_下._6_7_内部类._6_7_5_匿名内部类;

abstract class Device2{
    private String name;
    public abstract double getPrice();
    public Device2(){}
    public Device2(String name){
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

public class AnnoymousInner_Contrast extends Device2{
    public void test(Device2 d){
        System.out.println("购买了一个" + d.getName() + "，花费了" + d.getPrice());
    }

    @Override
    public double getPrice() {
        return 67.8;
    }

    public static void main(String[] args) {
        var ai = new AnnoymousInner_Contrast();
        ai.setName("键盘");
        ai.test(ai);
    }
}
